
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath %>">
<meta charset="UTF-8">
<link href="<%=basePath %>res/css/bootstrap.min.css" rel="stylesheet">
<title>理财列表页面</title>
<style type="text/css">
	.ftype{
		width: 100%;
		list-style: none ;
		margin:10px;
		height:60px;
	}
	
	.ftype li{
		float:left ;
		border-right:1px solid #d9534f ;
		border-bottom:1px solid #d9534f ;
		width:100px;
		height:50px;
		font-size: 16px;
		text-align: center ;
		line-height: 50px;
		border-radius: 5%;
		cursor: pointer ;
		color:#ffffff;
		margin-left:5px;
	}
	
	.ftype li:hover{
		background: #5cb85c ;
		
	}
	
	.css_red{
		background: #f8bab8;
	}
	
	.css_blue{
		background: #c2c6f9;
	}
	
	.main{
		width: 98%;
		height:100%;
		
	}
</style>

</head>
<body>
	<div class="main">	
	 
	
	<ul class="ftype">
		 
		<li class='css_blue'><a href="FinanceServlet?action=showList">全部</a></li>
		
		<c:forEach items="${listType }" var="type">
			<c:if test="${type.typeFlag==1 }">
				<li class='css_blue'><a href="FinanceServlet?action=showList&typeId=${type.typeID }">${type.typeName }</a></li>
			</c:if>
			<c:if test="${type.typeFlag==2 }">
				<li class='css_red'><a href="FinanceServlet?action=showList&typeId=${type.typeID }">${type.typeName }</a></li>
			</c:if>
		</c:forEach>
		
		<li  class="btn btn-success">余额: ${member.memberBalance }</li>
	</ul>

	<table class="table table-hover" style="width: 97%;margin:0px auto;">
		<tr>
			<td>序号</td> 
			<td>姓名</td>
			<td>理财类型</td>
			<td>金额</td>
			<td>备注</td>
			<td>分类</td>
			<td>操作
			<a href="FinanceServlet?action=showForm" class="btn btn-success">增加</a>
			</td>
		</tr>
		
		<!-- 定义一个变量 -->
		<c:set value="0" var="sum"></c:set>
		
		<c:forEach items="${list }" var="finance" varStatus="st"> 
			<c:if test="${finance.typeFlag == 1 }">
				<c:set var="css" value="success"></c:set>
				<c:set var="sum" value="${sum+finance.financeAmount }"></c:set>
			</c:if>
			<c:if test="${finance.typeFlag == 2 }">
				<c:set var="css" value="danger"></c:set>
				<c:set var="sum" value="${sum-finance.financeAmount }"></c:set>
			</c:if>
			<tr class="${css }">
				<td>${st.count }</td>
				<td>${finance.memberName }</td>
				<td>${finance.typeName }</td>
				<td>${finance.financeAmount }</td>
				<td>${finance.financeRemarks }</td>
				<td>
					<c:if test="${finance.typeFlag == 1 }">
						收入
					</c:if>
					<c:if test="${finance.typeFlag == 2 }">
						支出
					</c:if>
					
				</td>
				<td><a href="FinanceServlet?action=delete&id=${finance.financeID }" class="btn btn-danger" >删除</a>
					<a href="FinanceServlet?action=showForm&id=${finance.financeID }" class="btn btn-success">编辑</a>
				</td>
			</tr>
		</c:forEach>
		<tr>
			 
			<td>合计</td>
			<td></td>
			<td>金额</td>
			<td>${sum }</td>
			<td></td>
		</tr>
		
	</table>
	</div>
</body>
</html>